package com.wondersgroup.fjzlpt.console.dao.impl.xzqh;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import com.alibaba.fastjson.JSONArray;
import com.quick.framework.boot.repository.sql.bean.SQLBean;
import com.quick.framework.boot.repository.sql.bean.table.TableBean;
import com.quick.framework.boot.repository.sql.jdbcTemplate.impl.BaseJTDAOImpl;
import com.wondersgroup.fjzlpt.console.dao.inter.xzqh.XzqhDAO;

import java.util.ArrayList;
import java.util.List;

@Repository
public class XzqhDAOImpl extends BaseJTDAOImpl implements XzqhDAO{

	@Override
	@Autowired
	@Qualifier("TB_ZY_XZQH")
	public void setTb(TableBean tb) {
		super.setTb(tb);
	}
	
	
	@Override
	public JSONArray queryBySjdm(String sjdm) {
		JSONArray ary = new JSONArray();
		List list = new ArrayList<>();
		StringBuilder sbud = new StringBuilder("select * from TB_ZY_XZQH where 1=1 \n");
		if(!StringUtils.isEmpty(sjdm)){
			sbud.append("and SJXZQHDM like ? \n");
			list.add("%"+sjdm+"%");
		}
		sbud.append("order by XZQHDM");
		SQLBean sb = new SQLBean(sbud.toString(), list.toArray(new Object[list.size()]));
		JSONArray result = super.queryList(sb);
		ary.addAll(result);
		return ary;
	}
}
